package com.lyf.lottery.controller.assembler;


import com.github.pagehelper.PageInfo;
import com.lyf.lottery.controller.assembler.decorator.AbstractOptActivityBlindBoxRecordDecorator;
import com.lyf.lottery.model.po.OptActivityBlindBoxRecord;
import com.lyf.lottery.model.req.OptActivityBlindBoxRecordQuery;
import com.lyf.lottery.model.vo.OptActivityBlindBoxRecordAddVo;
import com.lyf.lottery.model.vo.OptActivityBlindBoxRecordQueryVo;
import com.lyf.lottery.model.vo.OptActivityBlindBoxRecordUpdateVo;
import com.lyf.lottery.model.vo.OptActivityBlindBoxRecordVo;
import org.mapstruct.DecoratedWith;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * OptActivityBlindBoxRecord 对象适配层
 * @author lyf
 **/
@Mapper
@DecoratedWith(AbstractOptActivityBlindBoxRecordDecorator.class)
public interface  OptActivityBlindBoxRecordAssembler {

    OptActivityBlindBoxRecordAssembler INSTANCE = Mappers.getMapper(OptActivityBlindBoxRecordAssembler.class);

    /**
     * 添加VO转entity
     *
     * @param vo
     * @return com.lyf.lottery.entity.OptActivityBlindBoxRecord
     * @date 2020/12/25
     */
    OptActivityBlindBoxRecord getOptActivityBlindBoxRecord(OptActivityBlindBoxRecordAddVo vo);
    /**
     * 修改VO转entity
     *
     * @param vo
     * @return com.lyf.lottery.entity.OptActivityBlindBoxRecord
     * @date 2020/12/25
     */
    OptActivityBlindBoxRecord getOptActivityBlindBoxRecord(OptActivityBlindBoxRecordUpdateVo vo);
    /**
     * entity集合转VO集合
     *
     * @param list
     * @return java.util.List
     * @date 2020/12/25
     */
    List<OptActivityBlindBoxRecordVo> getOptActivityBlindBoxRecordVoList (List<OptActivityBlindBoxRecord> list);

    /**
     * entity转VO
     *
     * @param entity
     * @return com.lyf.lottery.model.vo.OptActivityBlindBoxRecordVo
     * @date 2020/12/25
     */
    OptActivityBlindBoxRecordVo getOptActivityBlindBoxRecordVo (OptActivityBlindBoxRecord entity);

    /**
     * vo转value
     *
     * @param vo
     * @return com.lyf.lottery.value.OptActivityBlindBoxRecordQuery
     * @date 2020/12/25
     */
    OptActivityBlindBoxRecordQuery getOptActivityBlindBoxRecordQuery (OptActivityBlindBoxRecordQueryVo vo);

    /**
     * 分页转换
     *
     * @param pageInfo
     * @return com.github.pagehelper.PageInfo
     * @date 2020/12/25
     */
    default PageInfo<OptActivityBlindBoxRecordVo> convertPageInfo(PageInfo<OptActivityBlindBoxRecord> pageInfo) {
        PageInfo<OptActivityBlindBoxRecordVo> resultPage = new PageInfo<>();
        resultPage.setPageNum(pageInfo.getPageNum());
        resultPage.setPageSize(pageInfo.getPageSize());
        if (!CollectionUtils.isEmpty(pageInfo.getList())) {
        List<OptActivityBlindBoxRecordVo> list = getOptActivityBlindBoxRecordVoList(pageInfo.getList());
            resultPage.setList(list);
            resultPage.setTotal(pageInfo.getTotal());
        }
        return resultPage;
    }
}



